using System;
using System.Reflection;
using ValidationFramework;
using ValidationFramework.Reflection;

namespace ExampleLibraryCSharp
{
	public static class GetReflectionInfoFromValidationResult
	{
        public static Type GetTypeFromPropertyValidationResult(
            ValidationResult result)
        {
            var infoDescriptor = result.InfoDescriptor;
            var propertyDescriptor = (PropertyDescriptor) infoDescriptor;
            var typeDescriptor = propertyDescriptor.TypeDescriptor;
            return Type.GetTypeFromHandle(typeDescriptor.RuntimeTypeHandle);
        }

		
        public static MethodBase GetMethodInfoFromParameterValidationResult(
            ValidationResult result)
        {
            var infoDescriptor = result.InfoDescriptor;
            var parameterDescriptor = (ParameterDescriptor)infoDescriptor;
            var methodDescriptor = parameterDescriptor.Method;
            return MethodInfo.GetMethodFromHandle(methodDescriptor.RuntimeMethodHandle);
        }
		
	}
}
